package tests;
/**
 *
 * <p> implement as simple as possible, return the result by the test case.
 * access the program with InstanceBrige.msg();
 * </p>
 * @author nahumba
 *
 */
public class Testing extends ProjectTest {
	/**
	 *
	 * checks the test case for adding item to the library.
	 * the first two are books added by the dr
	 * the third is invalid add , made by student
	 * the forth and fifth done by doctor where the fifth is a jurnal not a book.
	 * since nothing is known on the data structer , only the ability of the system to run with out
	 * giving any exceptions is tested , and when an exception is thrown , it is tested .
	 *
	 * the serial nu,ber was not forced by the testing since it is not known howthe system will pick
	 * the new serial numbers (in order not enforce the programer implemitaion).
	 */
	public void testCase1(){
		try {
			setUp();
			SerialNumber Sbook;
			Sbook = InstanceBridge.addItem(Items[0],Persons[0]);
			assertNotNull(Sbook);
			Sbook = InstanceBridge.addItem(Items[1],Persons[0]);
			assertNotNull(Sbook);
			try {
				InstanceBridge.addItem(Items[2],Persons[1]);
				assertTrue(false);//never reach here
			} catch (Exception e) {
				assertTrue(true);//should reach here
			}
			Sbook = InstanceBridge.addItem(Items[3],Persons[2]);
			assertNotNull(Sbook);
			Sbook = InstanceBridge.addItem(Items[4],Persons[2]);
			assertNotNull(Sbook);


			tearDown();
		} catch (Exception e) {
			e.printStackTrace();
			assertTrue(false);//never reach here
		}

	}

	/**
	 * test the finding late returners for books (library abusers ) , by the data inserted.
	 * this cenario is by the accpetence tests in the doc.
	 * no data was checked since none can be checked
	 *
	 */
	public void testCase2(){
		try {
			setUp();

			InstanceBridge.FindLate(null, (Dr)Persons[0], 0);

			InstanceBridge.FindLate(Items[0], null, 0);
			try {
				InstanceBridge.FindLate(Items[0],(Dr)Persons[0],-1);
				assertTrue(false);//should not reach here
			} catch (Exception e) {
				assertTrue(true);//must reach here
			}
			InstanceBridge.FindLate(null, null, 3);

			tearDown();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
